/**
 * 
 */
package edu.cmich.cps.cps240.partyprincesspalace.hw06;

import static org.junit.Assert.*;

import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.util.Vector;

import org.junit.Test;

/**
 * @author roric1je
 *
 */
public class WireTest {

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#Wire()}.
	 */
	@Test
	public void testWire() {
		Wire wire = new Wire();
		assertNotNull(wire);
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#Wire(java.awt.Point)}.
	 */
	@Test
	public void testWirePoint() {
		Point spot = new Point(5, 5);
		Wire goodwire = new Wire(spot);
		assertNotNull(goodwire);
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#selectSegmentNearPoint(java.awt.Point)}.
	 */
	@Test
	public void testSelectSegmentNearPoint() {
		//Can't test this
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#makeHorizOrVert(java.awt.geom.Point2D, java.awt.geom.Point2D)}.
	 */
	@Test
	public void testMakeHorizOrVert() {
		Point2D x1 = new Point();
		Point2D x2 = new Point();
		Point2D y1 = new Point();
		Point2D y2 = new Point();
		x1.setLocation(4, 4);
		x2.setLocation(8, 8);
		y1.setLocation(4, 8);
		y2.setLocation(8, 4);
		assertNotNull(Wire.makeHorizOrVert(x1, y1));
		assertNotNull(Wire.makeHorizOrVert(x2, y2));
		assertNotNull(Wire.makeHorizOrVert(x1, y2));
		assertNotNull(Wire.makeHorizOrVert(x2, y1));
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#attemptAddSegment(java.awt.geom.Point2D, java.awt.geom.Point2D)}.
	 */
	@Test
	public void testAttemptAddSegment() {
		Point2D p0 = new Point(5, 5);
		Point2D p1 = new Point(5, 10);
		Point2D p2 = new Point(20, 25);
		Point p3 = new Point(5, 0);
		Wire wire = new Wire(p3);
		assertNotNull(wire.attemptAddSegment(p3, p0));
		assertNotNull(wire.attemptAddSegment(p0, p1));
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#snapToNearBySegmentPoint(java.awt.geom.Point2D)}.
	 */
	@Test
	public void testSnapToNearBySegmentPoint() {
		Point2D p0 = new Point(5, 5);
		Point2D p1 = new Point(30, 40);
		Point p2 = new Point(5, 0);
		Wire wire = new Wire(p2);
		assertNull(wire.snapToNearBySegmentPoint(p0));
		assertNull(wire.snapToNearBySegmentPoint(p1));
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#extendSelectedSegment(java.awt.Point)}.
	 */
	@Test
	public void testExtendSelectedSegment() {
		Point p0 = new Point(5, 5);
		Point test = new Point(5, 5);
		Point fail = new Point (50, 50);
		Wire wire = new Wire(p0);
		assertNotNull(wire.extendSelectedSegment(test));
		assertNotNull(wire.extendSelectedSegment(fail));
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#draw(java.awt.Graphics)}.
	 */
	@Test
	public void testDraw() {
		//Can't test this
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#isInputPin(edu.cmich.cps.cps240.partyprincesspalace.hw06.Pin)}.
	 */
	@Test
	public void testIsInputPin() {
		Wire wire = new Wire();
		WirePin wpin = new WirePin("", wire, null);
		assertFalse(wire.isInputPin(wpin));
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#isOutputPin(edu.cmich.cps.cps240.partyprincesspalace.hw06.Pin)}.
	 */
	@Test
	public void testIsOutputPin() {
		Wire wire = new Wire();
		WirePin wpin = new WirePin("", wire, null);
		assertEquals(-1, wire.isOutputPin(wpin));
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#attachTo(edu.cmich.cps.cps240.partyprincesspalace.hw06.Pin, edu.cmich.cps.cps240.partyprincesspalace.hw06.Pin)}.
	 */
	@Test
	public void testAttachToPinPin() {
		Vector<ChipPin> ins = new Vector<ChipPin>();
		Vector<ChipPin> outs = new Vector<ChipPin>();
		Rectangle rec = new Rectangle();
		Chip chip = new Chip(rec, ins, outs, "");
		ChipPin in = new ChipPin("", chip, null);
		ChipPin out = new ChipPin("", chip, null);
		ins.add(in);
		outs.add(out);
		Wire wire = new Wire();
		assertTrue(wire.attachTo(in));
		assertTrue(wire.attachTo(out));
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#attachTo(edu.cmich.cps.cps240.partyprincesspalace.hw06.Pin)}.
	 */
	@Test
	public void testAttachToPin() {
		Vector<ChipPin> ins = new Vector<ChipPin>();
		Vector<ChipPin> outs = new Vector<ChipPin>();
		Rectangle rec = new Rectangle();
		ChipPin in = new ChipPin("", null, null);
		ChipPin out = new ChipPin("", null, null);
		ins.add(in);
		outs.add(out);
		Chip chip = new Chip(rec, ins, outs, "");
		Wire wire = new Wire();
		assertTrue(wire.attachTo(in));
		assertTrue(wire.attachTo(out));
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#remove()}.
	 */
	@Test
	public void testRemove() {
		//Can't test this
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#isClose(java.awt.Point)}.
	 */
	@Test
	public void testIsClose() {
		Point lineSpot = new Point(5, 5);
		Wire wire = new Wire(lineSpot);
		Point nearSpot = new Point(7, 7);
		Point notNearSpot = new Point(20, 40);
		assertFalse(wire.isClose(nearSpot));
		assertFalse(wire.isClose(notNearSpot));
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#setName(java.lang.String)}.
	 */
	@Test
	public void testSetName() {
		Wire wire = new Wire();
		assertNotNull(wire.getName());
		wire.setName(null);
		assertNotNull(wire.getName());
	}

	/**
	 * Test method for {@link edu.cmich.cps.cps240.partyprincesspalace.hw06.Wire#getName()}.
	 */
	@Test
	public void testGetName() {
		Wire wire = new Wire();
		assertNotNull(wire.getName());
		wire.setName(null);
		assertNotNull(wire.getName());
	}
	
	
	@Test
	public void testUpdateName() {
		//Can't test this
	}

}
